<!DOCTYPE html>
<!-- manifest="/goods.appcache" -->
<html lang="en" manifest="/goods.appcache">
<head>
    <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>限时抢购</title>
</head>
<script src="../../js/edition.js"></script> 
<link rel="stylesheet" href="../../css/base.css">
<script>
        document.write("<l"+"ink rel='stylesheet' href='../../css/goods_detail.css?version="+edition+"'>")
</script>
<link rel="stylesheet" href="../../css/popover.css">
<script>
        document.write("<l"+"ink rel='stylesheet' href='../../css/style.css?version="+edition+"'>")
</script>
<script>
        document.write("<l"+"ink rel='stylesheet' href='../../css/index.css?version="+edition+"'>")
</script>
<script src="../../js/jquery.js"></script>
<script src="../../js/template.js"></script>
<script> 
        document.write("<s"+"cript type='text/javascript' src='../../js/url.js?version="+edition+"'></scr"+"ipt>"); 
</script>
<script> 
        document.write("<s"+"cript type='text/javascript' src='../../js/header.js?version="+edition+"'></scr"+"ipt>"); 
</script>
<!--<script> 
        document.write("<s"+"cript type='text/javascript' src='../../js/goods_detail.js?version="+edition+"'></scr"+"ipt>"); 
</script>-->
<script src="../../js/popover.js"></script>
<script src="../../js/magnifier.js"></script>
<script src="../../js/index_foot.js"></script>
<script src="../../js/jquery.cookie.js"></script>
<!--<script type="text/javascript" src="http://qzonestyle.gtimg.cn/qzone/openapi/qc_loader.js" data-appid="101353641" data-redirecturi="http://www.bgemall.com" charset="utf-8"></script>-->
<!-- <script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=403690515&debug=true" type="text/javascript" charset="utf-8"></script> -->
<script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
<!-- <script src="../js/popover_login.js"></script> -->
<script> 
        document.write("<s"+"cript type='text/javascript' src='../../js/login.js?version="+edition+"'></scr"+"ipt>"); 
</script>
<script src="../../js/cookie.js"></script>
<script> 
        document.write("<s"+"cript type='text/javascript' src='../../js/no_login.js?version="+edition+"'></scr"+"ipt>"); 
</script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script type="text/javascript" src="https://unpkg.com/vue-router/dist/vue-router.js "></script>
<link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.3.5/js/swiper.min.js"></script>
		<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.3.5/js/swiper.js"></script>

<!-- <script> 
document.write("<s"+"cript type='text/javascript' src='../../js/login_2.js?version="+edition+"'></scr"+"ipt>"); 
</script> -->
<!-- <script src="../../js/cart.js"></script> -->
<style>
#more {
    background: #ea2424;
    color: #fff;
    font-size: 14px;
    width: 120px;
    height: 34px;
    line-height: 34px;
    border-radius: 4px;
    text-align: center;
    cursor: pointer;
    margin: 50px auto;
}
.goods_img{ animation:myfirst 1.2s;}
@keyframes myfirst
{
0% {top: 144px; right:144px; }
100%{opacity: 0.6; top: -180px; right: 50%; margin-right:-778px;}
}
.login_container_bg{position: fixed; z-index:20; width: 100%; height: 100%; background: rgba(0,0,0,0.4); top: 0; display: none}
#login_container{position: absolute; z-index: 21; width: 300px; height: 400px; top: 50%; left: 50%; background: #fff; margin-top: -200px; margin-left: -150px; display: none}
</style>
<style type="text/css">
	.swiper-container {
      width: 100%;
      height: 70px;
    }
    .swiper-slide {
      text-align: center;
      display: -webkit-box;
      display: -ms-flexbox;
      display: -webkit-flex;
      display: flex;
      -webkit-box-pack: center;
      -ms-flex-pack: center;
      -webkit-justify-content: center;
      justify-content: center;
      -webkit-box-align: center;
      -ms-flex-align: center;
      -webkit-align-items: center;
      align-items: center;
      }
</style>
<body style="background:#fff">
	<div class="head_login ">
		<div class="mod_head_wrap" style="height: 40px;background: #F5F5F5;">
			<div class="lefts">好物好价，购吧就买<span><img src="../../img/base/head_left.png"/>0592-6031-095</span></div>
			<div class="rights mod_login">
				<div class="yes_or_no">
					欢迎来到购吧网，请选择 <a href="../login/login.html?type=2">登陆</a>或者 <a href="../login/register.html">注册</a>
				</div>
			</div>
		</div>
	</div>
    <header class="mod_head">
        <script>
            $(function(){
                var src=$('.mod_logo img').attr('src')
                $('.mod_logo img').attr('src','../'+src)
               
                // console.log($.cookie('user'))
                // $('.shopping_cart').append('<em></em>')
                // if($.cookie('user')!=''&&$.cookie('user')!=null){
                //     return true;
                // }
                // else{
                //     var url=window.location.href
                //     goodsId=url.split('=')[1]
                //     $('.login').attr('href','/login/login.html?goodsId='+goodsId)
                // }
            })   
        </script> 
    </header>
	<div class=" mod_floor" id="app" style="height: auto;" v-cloak>
		<div class="scarbuybanner">
			<img src="../../img/scarebuybanner.jpg" />
		</div>
		<div class="floor mod_floor" style="padding: 20px 0;">
	        <div class="time_boxs" >
	        	<div class="swiper-container">
				    <div class="swiper-wrapper">
				      	<div v-for="item in timeinfolist" :class="actshow==item.id?'swiper-slide time_item act':'swiper-slide time_item '"  @click="goodsinfos(item)"  >
			        		<i v-show="item.dataType ==0">昨天</i>
			        		<i v-show="item.dataType ==2">明天</i>
			        		{{item.time}}
			        		<span v-show="item.status == 2&&item.lest ==1">热门</span>
                    		<span v-show="item.status == 2&&item.lest !=1">抢购中</span>
                    		<span v-show="item.status == 1">即将开始</span>
		        		</div>
				    </div>
				    <div class="swiper-button-next"></div>
				    <div class="swiper-button-prev"></div>
				 </div>
	        </div>
	        <div class="mod_floor_content" style="position: relative;">
	            <div class="floor_content">
	            	<ul class="limits ">
	            		<li v-for="item in goodsinfolist" @click="goto(item)">    
	            			<div class="limit_img">
	            				<img :src="item.goodsImage">
	            			</div>
	            			<div class="limit_center">
	            				<h4>{{item.goodsName}}</h4>
	            				<div class="progress_box">
	            					<div class="progress_bar">
	            						<div class="progress" :style="{width:item.width+'%'}"></div>
	            					</div>
	            					<span>{{item.salesStorage}}/{{item.participateStorage}}</span>
	            				</div>
	            				<div class="price">
	            					限时价： ￥<span>{{item.activityPrice}}</span><del>￥{{item.goodsPrice}}</del>
	            				</div>
	            				<button v-if="item.salesStorage==item.participateStorage&&timestat.status == 2">已售罄</button>
                				<button v-else-if="timestat.status == 1">即将开始</button>
                				<button v-else @click.stop="gobuy(item.goodsId)">立即抢购</button>
	            			</div>
	            		</li>
	            	</ul>
	            	<p class="no_more" v-show="morepis">没有更多</p>
	            </div>
	        </div>
	    </div>
	</div>
    <footer class="mod_foot"></footer>
    <!-- 商品详情 end -->
</body>
<div class="popover_m" style="display:none"></div>
<div class="site_bg" style="display:none">
<span class="gb_01" style="display:block;width:18px;height:18px;background:url(../../img/base/icon_06.png) 0 0 no-repeat;float:right;margin:40px 30px 0 0;cursor: pointer; position: absolute; z-index: 1;right: 30px"></span>
<form class="register_tab">
<div class="login_bg" style="width:100%; border:0;">
<input type="hidden" name="" value="" class="qc_token">
<p class="login_title" style="width:100%; height:89px; line-height:89px; color:#fff; font-weight:600">用户登录</p>
<ul style="margin-top:20px;">
<li>
<em>账<i style="width: 24px; display: inline-block;"></i>号</em>
<input type="text" name="phone" id="phone" placeholder="请输入手机号">
<div class="error">请输入正确的用户名</div>
</li>
<li>
<em>密<i style="width: 24px; display: inline-block;"></i>码</em>
<input type="password" name="password" maxlength="18" id="password" placeholder="请输入密码">
<div class="error">请输入正确的密码</div>
</li>
</ul>
<div class="select">
<p class="fl_l">
还没账号？<a href="../login/register.html">前往注册>></a>
</p>
<a href="../login/retrieve_password.html" class="fl_r">忘记密码?</a>
</div>              
<div class="login_sub"><input type="submit" value="登录" id="login_sub"></div>
<!--<div class="s_login">
<dl>
<dd data-type="1"  style="width:50%"><span id="qqLoginBtn"></span><a href=""><img src="../../img/login/qq.png" alt="" srcset=""></a></dd>      
<dd style="width:50%" class="wx_login" data-type="3"><a><img src="../../img/login/wx.png" alt="" srcset=""></a></dd>-->
<!-- // popo_lo+='<dd data-type="2">'
// popo_lo+='<div id="wb_connect_btn">'
// popo_lo+='<wb:login-button onlogin="login" onlogout="logout"></wb:login-button>'
// popo_lo+='</div>'
// popo_lo+='<a><img src="../images/login/wb.png" alt="" srcset=""></a>'
// popo_lo+='</dd>' -->
<!--</dl>
</div>          -->
</div>
</form>
</div>
<div class="login_container_bg"></div>
<div id="login_container">
</div>
<!--<script type="text/javascript" src="../../js/swiper.min.js" ></script>-->
<script type="text/javascript">
	
	window.onload = function(){
    	var app = new Vue({
		  el: '#app',
		  data: {
		  		timeinfolist:{},
			    goodsinfolist:[],
			    actshow:'',
			    godsid:'',
			    timestat:{},
			    pageNo:1,
			    pageSize:6,
			    pageInfo:{},
			    loding:false,
			    morepis:false
		  },
		  methods: {
		    timeinfo: function () {
		    	let that =this
		    	  $.ajax({
	                    type: 'post',
	                    url: 'http://api.bgemall.com/shop/flash_sale_goods/getFlashSaleList',
	                    dataType:'json',
	                    data:{
	                    	type:"2"
	                    },
	                    success:function(res) {
						  	if(res.code==0){
	                    		that.timeinfolist = res.data
							  	if(that.timeinfolist.length>0){
							  		that.godsid = that.timeinfolist[0].id
								  	that.actshow = that.godsid
								  	that.timestat = that.timeinfolist[0]
								  	
								  	if(that.timeinfolist.length>1){
								  		for(let i = 0; i<that.timeinfolist.length;i++){
									  		let c = i+1
									  		if(that.timeinfolist[c]){
									  			if(that.timeinfolist[i].status == "2" &&that.timeinfolist[c].status == "1" ){
									  				that.$set(that.timeinfolist[i], "lest", '1')
									  				that.godsid = that.timeinfolist[i].id
								  					that.actshow = that.godsid
								  					that.goodsinfolist = []
//								  					that.swit(i)
//								  					console.log(0)
							  						that.goodsinfo(that.timeinfolist[i].id);
							  						setTimeout(function(){
														that.swit(i)
													},100)
							  						break;
										  		}
									  			else if(that.timeinfolist[i].status == "1"){
										  			that.goodsinfo()
										  			break; 
										  		}
									  		}
								  		}
								  	}else{
//								  		console.log(2)
							  			that.goodsinfo()
//							  			console.log(2)
							  		}
//								  	setTimeout(function(){
										that.swit()
//									},100)
							  	}
	                    	}
	                    }
	               });
		    },
		    goodsinfo:function(index){
		    	var that =this
		    	that.loding = false
		    	that.morepis = false
 				$.ajax({
	                    type: 'post',
	                    url: new_url+'shop/flash_sale_goods/getFlashSaleGoods',
	                    dataType:'json',
	                    data:{
	                    	id:index||that.godsid,
		    				getAll:'1',
		    				pageNo:that.pageNo,
		    				pageSize:that.pageSize
	                    },
	                    success:function(res) {
//	                    	that.goodsinfolist = {}
//							console.log(that.goodsinfolist)
//							console.log(res.data)
							if(res.code == 0){
								if(res.data.goodsList!=' '&&res.data.goodsList!=null){
									that.pageInfo = res.pageInfo
//									console.log(that.goodsinfolist  instanceof Array)
//									console.log(res.data.goodsList  instanceof Array)
									that.goodsinfolist = that.goodsinfolist.concat(res.data.goodsList) 
									that.loding = true
								  	for(let i = 0; i<that.goodsinfolist.length;i++){
								  		let a =that.goodsinfolist[i].salesStorage/that.goodsinfolist[i].participateStorage*100
								  		 that.$set(that.goodsinfolist[i], "width", a)
								  	}
								}else{
				                	that.morepis = true
				                }
//								else{
//									alert("没有更多了")
//								}
//								let a = that.goodsinfolist
								
							}
							
	                    }
	              });
		    },
		    goodsinfos:function(item){
		    	let that =this
//		    	console.log(item)
		    	that.timestat = item
		    	that.actshow = item.id||''
		    	that.pageNo= 1
		    	that.morepis = false
		    	that.loding = true
		    	that.goodsinfolist = []
 				$.ajax({
	                    type: 'post',
	                    url: new_url+'shop/flash_sale_goods/getFlashSaleGoods',
	                    dataType:'json',
	                    data:{
	                    	id:item.id,
		    				getAll:'1',
		    				pageNo:that.pageNo,
		    				pageSize:that.pageSize
	                    },
	                    success:function(res) {
	                    	that.pageInfo = res.pageInfo
						  	that.goodsinfolist = res.data.goodsList
						  	for(let i = 0; i<that.goodsinfolist.length;i++){
						  		let a =that.goodsinfolist[i].salesStorage/that.goodsinfolist[i].participateStorage*100
						  		 that.$set(that.goodsinfolist[i], "width", a)
						  	}
	                    }
	              });
		    },
		    goto(item){
		    	let that =this
		    	if(item.salesStorage==item.participateStorage){
		    		alert("商品已售罄")
		    	}else if(that.timestat.status == 1){
		    		alert("抢购未开始")
		    	}
		    	else{
		    		window.location.href="../goods/goods_detail.html?goodsId="+item.goodsId; 
		    	}
//		    	window.location.href="src/goods/goods_detail.html?goodsId="+item.goodsId; 
		    },
		   	swit(index){
	   			var swiper = new Swiper('.swiper-container', {
			    	slidesPerView: 7,
			    	initialSlide:index,
			    	spaceBetween: 10,
					centeredSlides : true,
//				    	loop: true,
//    					loopFillGroupWithBlank: true,
			      	navigation: {
				        nextEl: '.swiper-button-next',
				        prevEl: '.swiper-button-prev',
				    },
			    });
		   	},
		   	gobuy(goodsId){
		   		 var isFromCart='0'
                var goods_user=1+'&'+goodsId+'&'+0
                $.cookie('goods_user',goods_user,{path:'/'});
		   		if($.cookie('user')!=''&&$.cookie('user')!=null){
                    strs=$.cookie('user').split(",")
                    var token=''
                    for(var i in strs){
                        token=strs[6]
                    }
                    $.ajax({
		                url:new_url+'shop/buy/getSettleGoodsList',
		                data:{isFromCart:'0',token:token,goodsId:goodsId,buyNum:1},
		                dataType:'json',
		                type:'post',
		                success:function(n){ 
		                	if(n.code!='0'){
                                tc(n.message)
                                if(e.data='1005'){
                                    $.cookie('user','',{path:'/'})
                                    setTimeout(function(){
                                        window.location.href='/src/login/login.html?type=2'
                                    },500)
                                }
                                return false;
                            }
                            else{
                                tc(n.message)
                                if($.cookie('my_cookie')!=null&&$.cookie('my_cookie')!=''){
                                    $.cookie('my_cookie','',{path:'/'});
                                }
                                window.location.href='/src/cart/pay_commit.html' 
                            }
	                	}
	          		})
              	}else{ 
                    setTimeout(function(){
                        $('.popover_m, .site_bg').fadeIn()
                        $('.gb_01, .popover_m').click(function(){
                            $('.popover_m, .site_bg').fadeOut()
                        })
                    },200)
                }
		   	},
//		   	滚动加载
		   	createds(){
		   		let that =this
			   	window.onscroll = function(){
		   		//变量scrollTop是滚动条滚动时，距离顶部的距离
		   		var scrollTop = document.documentElement.scrollTop||document.body.scrollTop;
		   		//变量windowHeight是可视区的高度
		   		var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
		   		//变量scrollHeight是滚动条的总高度
		   		var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;
	               //滚动条到底部的条件
	               if(scrollTop+windowHeight==scrollHeight){
	                //写后台加载数据的函数
	                if(that.pageNo<=that.pageInfo.totalPages){
//	                	console.log('loding')
	                	if(that.loding){
//	                		console.log('goodsinfo')
	                		that.pageNo = that.pageNo+1
	         				that.goodsinfo()
	                	}
	                }else{
	                	that.morepis = true
	                }
	              }   
		       }
			}
		  },
		  created() {
		  	this.timeinfo()
		  	this.createds()
		  }
		})
    	}
    </script>
<script>
    // console.log(window.location.href)
    // (window.location.href).split('=')
var obj = new WxLogin({
    id:"login_container", 
    appid: "wx39e3c56e1f6d718e", 
    scope: "snsapi_login", 
    redirect_uri:"http%3a%2f%2fwww.bgemall.com/index.html",
    state: "",
    style: "",
    href: ""
});
</script>
</html>

<script>  
    document.write("<s"+"cript type='text/javascript' src='../../js/nav_hover.js?version="+edition+"'></scr"+"ipt>"); 
</script>
<script>
    $(function(){
		 $('.ac').eq(1).addClass("redcolor")
        // 底部小图标路径修改
        $('.foot_list>img').each(function(){
            var src = $(this).attr('src');
            $(this).attr('src','../../'+src);
        });
        // 底部链接修改
        $('.footer_ul a').each(function(){
            var newHref = $(this).attr('href');
            if(newHref!='javascript:;'){
                $(this).attr('href','..'+newHref);
            }
        });
    });
</script>   